package patrol.mobile.com.mobilepatrol.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.view.View;
import android.widget.Button;

import com.dl7.recycler.adapter.BaseQuickAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;
import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.utils.CommonUtil;

public abstract class CommonListWithSearchActivity extends BaseActivity {

    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    protected BaseQuickAdapter mAdapter;
    @BindView(R.id.searchView)
    protected SearchView searchView;
    @BindView(R.id.btn_search)
    protected Button btnSearch;

    @Override
    public void initTitle() {
        super.initTitle();
        iv_back.setImageResource(R.mipmap.up_white);
        iv_back.setVisibility(View.VISIBLE);
        iv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CommonUtil.exitActivityAndBackAnim(CommonListWithSearchActivity.this, true);
            }
        });
        tv_center_title.setVisibility(View.VISIBLE);
        tv_center_title.setText(initTitleName());
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_common_list_with_search;
    }

    @Override
    public void initData() {
        super.initData();
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        mAdapter = initAdapter();
        recyclerView.setAdapter(mAdapter);
        configAdapter();
    }

    protected abstract BaseQuickAdapter initAdapter();

    protected abstract String initTitleName();

    public void configAdapter() {

    }

    @Override
    public void setListener() {

    }

}
